//
// Copyright (c) 2024 BPer
//
#ifndef __BPerLivingVideoCaptureHandle__
#define __BPerLivingVideoCaptureHandle__
#include <bperavutil/video/BPerYuvConvert.h>
#include <bperutil/buffer/BPerVideoBuffer.h>
#include <bperutil/BPerAvInfoType.h>


class BPerVideoCaptureHandle
{
public:
	BPerVideoCaptureHandle(BPerVideoInfo *pcontext);
	virtual ~BPerVideoCaptureHandle(void);
    void reset(BPerVideoInfo* p_config);

    void putBuffer(int64_t startTime, uint8_t *pBuffer, int32_t BufferLen);
    void putBufferAndroid(int64_t startTime, uint8_t *pBuffer, int32_t BufferLen);
    void putBufferAndroid2(int64_t startTime, uint8_t *data_y, uint8_t* data_u,uint8_t* data_v);
    void putBufferNv21(int64_t startTime, uint8_t *data_y, uint8_t* data_u);
    void putBuffers();
	void saveFile(char* fileName,double Time, uint8_t *pBuffer, int32_t BufferLen);
	void initstamp();
	void startLoop();
	long m_start_time;
	int32_t m_isCapture;
	int32_t m_isLivingCaptrue;
	int32_t m_isFilm;
	void  setVideoBuffer(BPerVideoBuffer *pbuf);
	void  setLivingVideoBuffer(BPerVideoBuffer *pbuf);
	void  setFilmVideoBuffer(BPerVideoBuffer *pbuf);
	void  setPreVideoBuffer(BPerVideoBuffer *plist);
	void  setCaptureFormat(int32_t pformat);
private:

	BPerVideoBuffer *m_out_videoBuffer,*m_pre_videoBuffer,*m_living_out_videoBuffer,*m_film_out_videoBuffer;
	BPerFrame m_videoFrame;
	BPerYuvConvert m_yuv;
	uint8_t *m_buf,*m_androidBuf;
    int32_t m_width,m_height,m_bufLen,m_ylen,m_ulen;
	int64_t vtick;
	int64_t curstamp,basesatmp;
	int m_encoderVideoFormat;
	int m_captureVideoFormat;
	int32_t m_rotate;
	bool m_isHardwareEncoder;



};

#endif
